<template>
  <div class="rich-text">
    <template>
      <div v-if="mode === 'edit'">
        <div v-html="text"></div>
      </div>
      <div v-else>{{ value }}</div>
    </template>
  </div>
</template>

<script>
export default {
  name: "richText",
  components: {},
  props: {
    value: {},
    mode: {
      default: "edit", // 编辑模式和 edit， 展示模式 view
    },
    readonly: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    text: {
      type: String,
      default: '<p style="color:red">这是富文本</p>',
    },
  },
  data() {
    return {

    };
  },
  computed: {},
  created() {
  },
  mounted() {
    if (this.value) {
      this.text = this.value;
      if (this.mode == "view") {
        this.disabled = true;
      }
    }
  },
  methods: {
  },
};
</script>
<style lang="scss" scoped>
.rich-text {
  width: 100%;
}
</style>
